#pragma once

#include "ui_mainclass.h"
#include <QDockWidget>
#include <QListView>
#include "scriptmodel.h"
using namespace std;
class SceneView;
class Node;
class Title;
class Path;
class QAction;
class scriptModel;

class mainClass : public QMainWindow
{
	Q_OBJECT

public:
	mainClass(QWidget *parent = 0, Qt::WFlags flags = 0);
	~mainClass();
	QTreeView* propertyTree;

	const enum mode_t {schemeEditor, scriptEditor, imbalanceViewer};
private:
	
	Ui::mainClassClass ui;

	mode_t mode;
	QStatusBar *statusbar;
	SceneView *scene;
	QGraphicsView *view;
	QMenu *itemMenu;
	QHBoxLayout *layout;
	QListWidget *listItems;

	QString filePath;
	//scriptModel *scrModel;
	map<QString, scriptModel *> scrModelList;
	QAction *NewDoc;
	QAction *OpenDoc;
	QAction *SaveDoc;
	QAction *SaveAsDoc;
	QAction *Quit;
	QAction *PrintDoc;
	QAction *CutItem;
	QAction *CopyItem;
	QAction *PasteItem;
	QAction *DeleteItem;
	QAction *SendToFront;
	QAction *SendToBack;
	QAction *Execution;
	QAction *EditScheme;
	QAction *EditScript;
	QAction *Execute;
	QAction *tbFile;
	QAction *tbEdit;
	QAction *tbMode;
	QAction *tbView;
	QAction *Properties;
	QAction *Scale50;
	QAction *Scale75;
	QAction *Scale100;
	QAction *Scale150;
	QAction *Scale250;
	QAction *ScaleUp;
	QAction *ScaleDown;
	QAction *Net;
	QAction *HScroll;
	QAction *VScroll;
	QAction *Info;

	QMenu *File;
	QMenu *Edit;
	QMenu *Mode;
	QMenu *Window;
	QMenu *View;
	QMenu *Information;

	QMenu *Position;
	QMenu *Scale;

	QMenuBar *menuBar;
	QMenuBar *menuBarFile;
	QToolBar *toolBarFile;
	QMenuBar *menuBarEdit;
	QToolBar *toolBarEdit;
	QMenuBar *menuBarMode;
	QToolBar *toolBarMode;
	QMenuBar *menuBarWindow;
	QMenuBar *menuBarView;
	QToolBar *toolBarView;
	QMenuBar *menuBarInformation;
	QToolBar *toolBarInformation;

	QLabel * scaleLabel, *positionLabel;
	QSlider *scaleSlider;


	QDockWidget *dockProperties, *dockScript;
	QDoubleSpinBox *sbAddRowScript;
	//QListView *scriptView;
public:
	QPushButton *bAddRowScript;
	QComboBox  *cmScriptList;
	QComboBox *cmPathList;
private slots:
	void scaleView(qreal scaleFactor);
	void scaleUp(){scaleView(1.1);}
	void scaleDown(){scaleView(0.9);}
	void scale50(){setZoom(50);}
	void scale75(){setZoom(75);}
	void scale100(){setZoom(100);}
	void scale150(){setZoom(150);}
	void scale250(){setZoom(250);}
	void setZoom(int percentZoom);
	void cursorPosition(bool paint, int x, int y);
	void save();
	void saveAs();
	void open();
	void create();
	void setMode(mode_t mode);
	void setPathListInScript();
	void setSchemeMode(){ setMode(schemeEditor); }
	void setScriptMode(){ setMode(scriptEditor); setPathListInScript(); currentScriptChanged("");}
	void useCurrentTime(int state);
	void addTransaction();
	void addScript();
	void removeScript();
	void editScript();
	void importScript();
	void currentScriptChanged(const QString &name);
	void currentPipeChanged(const QString &name);
private:
	void createMenu();
	void createListItems();
	void saveDoc();
	void deleteScript();
	bool checkPipeName(const QString &name);
};
